package com.briup.common.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: vanse
 */
public class ClassifyAndEntityUtil {
    // 将一个分类名称对应一个实体uuid关系的map转换为一个分类名称对应多个实体uuid的关系map
    public static Map<String, List<String>> toClassifyAndEntity(List<Map<String, String>> list) {
        Map<String, List<String>> map = new HashMap<>();
        list.forEach(m -> {
            String classifyName = m.get("classifyName");
            String entityUuid = m.get("entityUuid");
            if (!map.containsKey(classifyName)) {
                map.put(classifyName, new ArrayList<>());
            }
            if(entityUuid != null){
                map.get(classifyName).add(entityUuid);
            }
        });
        return map;
    }
}
